//
//  DQTextfiled.m
//  DQBaisibudejie
//
//  Created by 杜倩 on 16/9/2.
//  Copyright © 2016年 杜倩. All rights reserved.
//

#import "DQTextfiled.h"

@implementation DQTextfiled
//xib加载完自动调用方法
-(void)awakeFromNib{
    //改变光标颜色
    self.tintColor = [UIColor whiteColor];
    //监听方法----开始编辑
    [self addTarget:self action:@selector(beginEdit) forControlEvents:UIControlEventEditingDidBegin];
    //结束编辑--监听
    [self addTarget:self action:@selector(endEdit) forControlEvents:UIControlEventEditingDidEnd];
}

#pragma mark 开始编辑
-(void)beginEdit{
    NSMutableDictionary *dict=[NSMutableDictionary dictionary];
    //设置字体颜色为白色--属性设置
    dict[NSForegroundColorAttributeName] = [UIColor whiteColor];
    self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder attributes:dict];
}
#pragma mark 结束编辑
-(void)endEdit{
    NSMutableDictionary *dict=[NSMutableDictionary dictionary];
    //设置字体颜色为白色--属性设置
    dict[NSForegroundColorAttributeName] = [UIColor grayColor];
    self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder attributes:dict];}
@end
